#include <ClassFactory.h>
#include <iostream>
#include <EDesignerCore.h>

ClassFactory::ClassFactory( ): QObject()
{

}

ClassFactory::~ClassFactory()
{

}

void ClassFactory::addFactoryObject(QSharedPointer<ClassFactoryObject> factoryObj)
{
    m_factoryObjList.push_back(factoryObj);
}

EObject *ClassFactory::creatObject(const QString &typeName)
{
    EObject* objPtr = NULL;
    //QSharedPointer<QObject> objPtr;
    for(int i = 0; i < m_factoryObjList.size(); i++)
    {
        objPtr = m_factoryObjList[i]->creatObject(typeName);
        if(objPtr != NULL)
        {
            break;
        }
    }
    return objPtr;
}

QStandardItem *ClassFactory::creatItem(const QString &typeName)
{
    QStandardItem* itemPtr = NULL;
    for(int i = 0; i < m_factoryObjList.size(); i++)
    {
        itemPtr = m_factoryObjList[i]->creatItem(typeName);
        if(itemPtr != NULL)
        {
            break;
        }
    }
    return itemPtr;
}
